package main

import (
	"easy_http/http_controller"
	"easy_http/http_server"
	"easy_http/http_utils"
	"easy_http/http_utils/http_log"
	"net/http"
)

func main() {
	en := http_server.New()
	http_utils.ConfigInit() // 配置初始化
	//http_orm.NewGormORM("", "")
	en.Use(http_log.LogMiddleware()) // 请求日志中间件
	// template 渲染
	en.LoadHTMLGlob("./http_templates/*")
	en.Static("/assets/", "./http_static/css")
	en.GET("/students", func(ctx *http_server.Context) {
		ctx.HTML(http.StatusOK, "index.html", nil)
	})
	// 静态资源服务
	en.Static("/assets/", "./http_static")
	v1 := en.Group("/v1")
	v1.GET("/login", func(ctx *http_server.Context) {

		http_utils.NewSuccess(ctx, 2000, "sss")
	})
	en.GET("/hello/:name", func(ctx *http_server.Context) {
		name := ctx.Param("name")
		http_utils.NewSuccess(ctx, 2000, name)
	})
	en.POST("/sign_up", http_controller.SignUp)
	err := en.Run(":8080")
	if err != nil {
		panic(err)
	}
}
